package top.hjcwzx.wrench.mqtt.strategy.impl;

import top.hjcwzx.wrench.mqtt.event.MqttMessageEvent;
import top.hjcwzx.wrench.mqtt.service.publish.MqttEventPublisher;
import top.hjcwzx.wrench.mqtt.strategy.MqttMessageHandler;

import java.util.List;
import java.util.Map;
import java.util.function.Consumer;


public class EventPublishStrategy implements MqttMessageHandler {

    private final MqttEventPublisher publisher;

    public EventPublishStrategy(MqttEventPublisher publisher) {
        this.publisher = publisher;
    }

    @Override
    public void handleMessage(String topic, String payload, Map<String, List<Consumer<Object>>> topicHandlerMap) {
        publisher.publish(new MqttMessageEvent(this, topic, payload));
        // 不直接调用回调
    }
}
